from fastapi.responses import JSONResponse

class Result:
    def __init__(self, data: any, msg: str = "success", code: int = 200):
        self.data = data
        self.msg = msg
        self.code = code

    @staticmethod
    def success(data: any, status_code: int = 200, media_type: str = "application/json, charset=utf-8"):
        data = Result(data=data, msg="success", code=status_code)
        return JSONResponse(content=data, status_code=status_code, media_type=media_type)
    
    @staticmethod
    def error(data: any,msg: str, status_code: int = 400, media_type: str = "application/json, charset=utf-8"):
        data = Result(data=data, msg=msg, code=status_code)
        return JSONResponse(content=data, status_code=status_code, media_type=media_type)
    
        